// 流水灯模块
module led_shifting (
    input                   clk,        // 时钟信号
    input                   rst_n,      // 复位信号
    input                   left_cmd,   // 流水灯左移信号
    input                   right_cmd,  // 流水灯右移信号
    input                   s_p,        // 秒级分频脉冲信号
    output  reg [7:0]       led=8'hff   // LED灯输出信号
);

    always @(posedge clk or negedge rst_n) begin
        if(!rst_n) led <= 8'hff;
        else if(led == 8'hff) led <= 8'h01;
        else begin
            if(left_cmd && s_p)
                led <= {led[6:0], led[7]};
            if(right_cmd && s_p)
                led <= {led[0], led[7:1]};
        end
    end

endmodule  //led_shifting